package com.example.authserver.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import java.util.Map;

@Controller
@SessionAttributes("authorizationRequest")
public class GrantController {
    @RequestMapping(value = "/custom/confirm_access")
    public String getAccessConfirmation(Map<String,Object> model, Model uiModel){
        System.err.println(JSONObject.toJSONString(model,true));
        AuthorizationRequest authorizationRequest = (AuthorizationRequest) model.get("authorizationRequest");
        uiModel.addAttribute("clientId",authorizationRequest.getClientId());
        uiModel.addAttribute("scopes",authorizationRequest.getScope());
        return "grant";
    }
}
